'This implements an ordered collection which uses runs to minimise the amount of data that it holds. Basically it should be used if you know that an ordered collections is giong to contain a lot of runs of eactly the same data. Implemented to allow simultation playback, since the ordered collctions which that generates are so big that the complier falls over, though most of it is extremely repetetive. This should be totally abstracted. The user should not be a ble to see the difference between an ordered collection and a ComrpessedOrderedCollection. This has a lot in common with RunArray, and the two should probably share implementation. but I could not do some of the things I wanted with the RunArray code, so this is all done on its own.
Some of this could be made faster by adding a cache of the start and finish indices of each run, but since I envisage that most additions etc. will be to and from the end those are not included. In addition I have implemented the bare essentials of this for what I need it for - i.e. add to the end and take off the beginning.'!
!CompressedOrderedCollection class methodsFor: 'instance creation'!
new
"Answer a new empty instance of OrderedCollection.
Have to use basicNew because OrderedCollection re-defines new"
^(self basicNew) initialize!
new: aNumber
"Answer a new empty instance of OrderedCollection. This is here for compatibility, it totally ignores the parameter, since it is impossible to predict how many runs will be required.
Have to use basicNew because OrderedCollection re-defines new"
^self new! !
'From Smalltalk-80, Version 2.3 of 13 June 1988 on 18 May 1989 at 11:00:20 am'!
!OrderedCollection methodsFor: 'converting'!
asCompressedOrderedCollection
"Convert this ordered collection into a compressed version of itself."